export default function cachepromise_arrayofstring<
    T extends (...arg: V) => Promise<R>,
    R extends any,
    V extends Array<string | string[]>
>(fn: T): T {
    const sourcecache = new Map<V, Promise<R>>();
    return (async (...key: V): Promise<R> => {
        console.log(key);
        const found = mapgetofobjectequalkey(sourcecache, key);
        if (found) {
            return found;
        }
        const loadpro = Reflect.apply(fn, void 0, key);
        sourcecache.set(key, loadpro);
        return loadpro;
    }) as T;
}
function mapgetofobjectequalkey<T extends Map<K, any>, K extends any>(
    map: T,
    key: K
): GetMapValue<T> | undefined {
    return Array.from(map.entries()).find(([k]) => isEqual(k, key))?.[1];
}

import isEqual from "lodash/isEqual.js";
type GetMapValue<T extends Map<any, any>> = T extends Map<any, infer R>
    ? R
    : any;
